import apiClient from '@/api/apiClient';
import { SuggestType } from '@/pages/setting/suggest/type';

import { ListData } from '#/entity';

export enum BackApi {
  List = '/management/backs',
  Back = '/management/back',
}

// /management/backs
const list = (searchForm) =>
  apiClient.get<ListData<SuggestType>>({ url: BackApi.List, params: searchForm });

const create = (data: any) =>
  apiClient.post({
    url: BackApi.Back,
    data,
  });

const deleteBatch = (data: { ids: string }) =>
  apiClient.delete({
    url: `${BackApi.Back}`,
    params: data,
  });

// /management/back/{id}
const update = (id: number, data: any) =>
  apiClient.put({
    url: `${BackApi.Back}/${id}`,
    data,
  });

export default {
  list,
  create,
  deleteBatch,
  update,
};
